package com.zlw.main.audioeffects.utils;

import android.content.Context;


import java.util.concurrent.atomic.AtomicBoolean;

public class AppConfig {
    public static final String TAG = "AppConfig";
    private static AppConfig appConfig = null;
    private boolean sOnlyLocal = false;
    private boolean sOffLine = true;
    private boolean mIsBusinessModel = false;
    private boolean mIsDeviceHasNavigationBar = false;
    private Context mContext = null;
    private boolean mIsUseNewMusicLibInsteadOfOldMusicLib = false;
    private int mMusicLibType = AppConsts.SOURCE_TYPE_XIAMI;
    private ConfigVal configVal = new ConfigVal();
    private AtomicBoolean isConfigValGot = new AtomicBoolean(false);
    
    private AppConfig(Context context) {
        mContext = context;
    }
    
    public synchronized static AppConfig createInstace(Context context){
        if(appConfig == null) {
            appConfig = new AppConfig(context);
        }
        appConfig.sOnlyLocal = true;
        appConfig.sOffLine = true;
        appConfig.mIsDeviceHasNavigationBar = true;
        if(appConfig.mIsUseNewMusicLibInsteadOfOldMusicLib) {
            appConfig.mMusicLibType = AppConsts.SOURCE_TYPE_ATMD;
        }else {
            appConfig.mMusicLibType = AppConsts.SOURCE_TYPE_XIAMI;
        }
        return appConfig;
    }
    
    public boolean getIsHasNavigationBar(){
        return mIsDeviceHasNavigationBar;
    }
    
    public synchronized static AppConfig getInstance(){
        return appConfig;
    }
    
    //设置是否是本地的开关
    public void setIsLocal(boolean value) {
        sOnlyLocal = value;
    }
    //获取是否市本地的开关
    public boolean getIsLocal() {
        return sOnlyLocal;
    }
    
    //设置是否是本地的开关
    public void setIsOffLine(boolean value) {
    	sOffLine = value;
    }
    //获取是否市本地的开关
    public boolean getIsOffLine() {
        return sOffLine;
    }
    
    public boolean isUseNewMusicLibInsteadOfOldMusicLib() {
        return mIsUseNewMusicLibInsteadOfOldMusicLib;
    }
    
    public void setMusicLibType(int value) {
        appConfig.mMusicLibType = value;
    }
    
    public int getMusicLibType() {
        return appConfig.mMusicLibType;
    }
    
    public int getMusicLibAllType() {
        return AppConsts.SOURCE_TYPE_ALL;
    }
    
    public boolean getIsBusinessModel() {
        return mIsBusinessModel;
    }
    
    public void setIsBusinessModel(boolean flag) {
        mIsBusinessModel = flag;
    }
    
    public synchronized ConfigVal getConfigVal() {
        return configVal;
    }

    public synchronized void setConfigVal(ConfigVal configVal) {
        this.configVal = configVal;
    }
    
    public boolean getIsConfigValGot() {
        return isConfigValGot.get();
    }

    public void setIsConfigValGot(boolean isConfigValGot) {
        this.isConfigValGot.set(isConfigValGot);
    }
}
